Ext.define('Desktop.LoginWindow', {
	extend : 'Ext.window.Window',
	title : "登录系统",
	width : 300,
	height : 220,
	id : "loginwindow",
	modal : true,
	closable : false,
	layout : "fit",
	items : [{
		xtype : "form",
		id : "loginform",
		defaults : {
			labelSeparator : ':',
			labelWidth : 30,
			width : 170,
			allowBlank : false,
			labelAlign : 'left',
			msgTarget : 'side'
		},
		defaultType : 'textfield',
		items : [{
					xtype : "displayfield",
					hideLabel : true,
					margin : "10 10 10 100",
					value : "<font color=blank size=3><b>个人信息中心</b></font>"
				}, {
					fieldLabel : "帐号",
					selectOnFocus : true,
					regex : /([A-Za-z]{1})\w{1,19}/,
					regexText : '用户名格式有误',
					name : 'username',
					id : "username",
					margin : "20 10 10 50"
				}, {
					name : 'password',
					id : "password",
					fieldLabel : '密码',
					inputType : 'password',
					margin : "10 10 10 50"
				}, {
					xtype : "button",
					text : '登录',
					width : 50,
					margin : "10 10 10 80",
					handler : function(btn) {
						var form = btn.ownerCt;
						var basic = form.getForm();
						var nameField = basic.findField("username");
						var nameValue = nameField.getValue();
						var passField = basic.findField("password");
						var passValue = passField.getValue();
						Ext.Ajax.request({
							url : "/buy360/jsonlogin/oper!login.action",
							method : "POST",
							timeout : 10000,
							params : {
								userName : nameValue,
								passWord : passValue
							},
							success : function(response, opts) {
								if (Ext.JSON.decode(response.responseText).message == "success") {
									Ext.Msg.alert("提示","登录成功");
									Ext.getCmp("loginwindow").close();
								}else{								
									Ext.Msg.alert("提示","帐号/密码错误");
									nameField.focus();
								}
								
							}
						});
					}
				}, {
					xtype : "button",
					text : '退出',
					width : 50,
					margin : "10 10 10 20",
					handler : function() {
						Ext.Msg.alert("提示", "暂时没有实现该功能");
					}
				}]
	}]
});
